---
category: String
created: '2021-04-21'
title: Check if a string consists of a repeated character sequence
updated: '2021-10-13'
---

**JavaScript version**

```js consistsRepeatedSubstring.js
const consistsRepeatedSubstring = (str) => `${str}${str}`.indexOf(str, 1) !== str.length;
```

**TypeScript version**

```ts consistsRepeatedSubstring.ts
const consistsRepeatedSubstring = (str: string): boolean => `${str}${str}`.indexOf(str, 1) !== str.length;
```

**Examples**

```js examples.js
consistsRepeatedSubstring('aa'); // true
consistsRepeatedSubstring('aaa'); // true
consistsRepeatedSubstring('ababab'); // true
consistsRepeatedSubstring('abc'); // false
```
